#ifndef THUMBNAILVIEW_H
#define THUMBNAILVIEW_H

#include <QListWidget>
#include <QImage>

class ThumbnailView : public QListWidget
{
    Q_OBJECT

public:
    explicit ThumbnailView(QWidget *parent = nullptr);
    void setPages(const QList<QImage>& pages);
    void setPDFMode(bool isPDF, int totalPages = 0);
    void updatePDFPage(int pageIndex, const QImage& image);
    void retranslateUi();
    
public slots:
    void setCurrentPage(int index);

signals:
    void pageSelected(int index);
    void pageRequested(int pageIndex);  // 请求加载指定页面

private:
    QList<QImage> m_pages;
    bool m_isPDFMode;
    int m_totalPDFPages;
    int m_lastSelectedIndex;  // 记录上次选中的索引，用于防止重复点击
    void createThumbnail(const QImage& image, int index);
    void createPDFThumbnail(int pageIndex);
};

#endif // THUMBNAILVIEW_H 